package com.imooc.luckymoney.luck;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

// import org.springframework.web.bind.annotation.RequestMapping;
// import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author andy
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    private LimitConfig limitConfig;

    // @RequestMapping(value = "/hello", method = RequestMethod.GET) # 旧版本
    @GetMapping("/hi")
    public String say() {
        return "Hello World" + limitConfig.getDescription();
    }

    @GetMapping("/hi2/{id}")
    public String say2(@PathVariable("id") Integer id) {
        return "id : " + id;
    }

    @GetMapping("/hi3")
    public String say3(@RequestParam(value = "id", required = false, defaultValue = "0") Integer myId) {
        if( myId == null){
            return "None";
        }else {

            return "id: " + myId;
        }
    }
}
